﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB.YJKControls;
using HYElectricSystemDiagram.DataStruct;
using HYElectricSystemDiagram.FormSet;

namespace HYElectricSystemDiagram
{
	public partial class FormSelectTypeSystem : HYBaseForm
	{
		public FormSelectTypeSystem(string strFormName, ExternalCommandData m_commandData = null)
		{
			this.InitializeComponent();
			this.Text = strFormName;
			this.name = strFormName;
			this.ReadData();
			this.commandData = m_commandData;
			int setViewType = GetXmlData.GetSetViewType(true, 0);
			if (setViewType == 0)
			{
				this.radioDraw.Checked = true;
				return;
			}
			if (setViewType == 1)
			{
				this.radioCurView.Checked = true;
				return;
			}
			this.radioAllProgram.Checked = true;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (this.radioDraw.Checked)
			{
				this.m_radio = 0;
			}
			else if (this.radioCurView.Checked)
			{
				this.m_radio = 1;
			}
			else if (this.radioAllProgram.Checked)
			{
				this.m_radio = 2;
			}
			base.DialogResult = DialogResult.OK;
		}

		private void button2_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void ReadData()
		{
			switch (0)
			{
			case 0:
				this.radioDraw.Checked = true;
				return;
			case 1:
				this.radioCurView.Checked = true;
				return;
			case 2:
				this.radioAllProgram.Checked = true;
				return;
			default:
				return;
			}
		}

		private void SaveData()
		{
		}

		public int GetSelectType()
		{
			return this.m_radio;
		}

		private void btnSet_Click(object sender, EventArgs e)
		{
			new FormSystemDiagramSet(this.name, this.commandData).ShowDialog();
		}

		private void FormSelectTypeSystem_FormClosed(object sender, FormClosedEventArgs e)
		{
			if (this.radioDraw.Checked)
			{
				this.m_radio = 0;
			}
			else if (this.radioCurView.Checked)
			{
				this.m_radio = 1;
			}
			else if (this.radioAllProgram.Checked)
			{
				this.m_radio = 2;
			}
			GetXmlData.GetSetViewType(false, this.m_radio);
		}

		private void FormSelectTypeSystem_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.radioDraw.Checked)
			{
				this.m_radio = 0;
			}
			else if (this.radioCurView.Checked)
			{
				this.m_radio = 1;
			}
			else if (this.radioAllProgram.Checked)
			{
				this.m_radio = 2;
			}
			GetXmlData.GetSetViewType(false, this.m_radio);
		}

		public int m_radio;

		private string name = "";

		private ExternalCommandData commandData;
	}
}
